package cn.alibab.cangku.dao;


import cn.alibab.cangku.model.BizProductCategory;
import cn.alibab.cangku.model.BizProductStock;
import cn.alibab.cangku.vo.ProductInputVo;
import cn.alibab.cangku.vo.ProductOutputVo;
import cn.alibab.cangku.vo.ProductVo;
import org.apache.ibatis.annotations.Select;

import java.util.List;

/**
 * @author Xd
 * @create 2020-07-10 11:38
 */
public interface ProductDao {
    //查询所有物品库存
    @Select("select pName,model,unit,stock from biz_product as p inner join `biz_product_stock` as s where p.p_num = s.p_num")
    List<ProductVo>  getAllProduct();
    //查询所有物品库存
//    @Select("select name,model,unit,stock from biz_product as p inner join `biz_product_stock` as s where p.p_num = s.p_num")
//    List<ProductVo>  getAllProduct();
    //查询所有入库物品
    @Select("SELECT  NAME,phone,operator,STATUS,in_num,product_number,TYPE  FROM `biz_supplier` AS bs INNER JOIN `biz_in_stock` " +
            "AS bis  WHERE bs.id = bis.supplier_id\n")
    List<ProductInputVo>  getAllProductInput();


    @Select("SELECT  *  FROM biz_product_stock WHERE p_num=#{pNum} ")
    BizProductStock findProductStockByPNum(String pNum);
    //通过pNume获取对应的物资信息
    @Select("SELECT  *  FROM `biz_product_stock` WHERE p_num " +
            "=(SELECT  p_num FROM biz_product WHERE pName=#{pName}) ")
    BizProductStock findProductStockByPName(String pName);
    //查询出库产品
    @Select("SELECT out_num,TYPE,remark,priority,product_number,NAME,status,phone FROM `biz_consumer` AS bc \n" +
            "INNER JOIN `biz_out_stock` AS boc WHERE bc.`id`=boc.consumer_id")
    List<ProductOutputVo>  getAllOutProduct();

    //查询物资分类的以及分类
    @Select("select  *from `biz_product_category` where pid=0")
    List<BizProductCategory> findAllProductCategory();

    //物品分区管理二级分类
    @Select("SELECT  *  FROM `biz_product_category` where pid = #{pid}")
    List<BizProductCategory> findAllProductTwoCategory(Long pid);

    @Select("select  *from `biz_product_category`")
    List<BizProductCategory> getCategory();

}
